<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Dettaglio alunno</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="../../css/main.css" rel="stylesheet" />
<link href="../../css/skins/aqua/theme.css" type="text/css" rel="stylesheet"  />
<script type="text/javascript" src="../../js/prototype.js"></script>
<script type="text/javascript" src="../../js/scriptaculous.js"></script>
<script type="text/javascript" src="../../js/controls.js"></script>
<script type="text/javascript" src="../../js/page.js"></script>
<script type="text/javascript" src="../../js/calendar.js"></script>
<script type="text/javascript" src="../../js/lang/calendar-it.js"></script>
<script type="text/javascript" src="../../js/calendar-setup.js"></script>
<script type="text/javascript">
function go(par, evento){
    if(par == 2){
        if(!confirm("Sei sicuro di voler cancellare questo evento?"))
            return false;
    }
    $('_i').value = evento;
    $('action').value = par;
    var url = "<?php print $_SESSION['__config__']['root_site'] ?>admin/adm_events/events_manager.php";
    //alert(url);
	var req = new Ajax.Request(url,
			  {
			    	method:'post',
			    	parameters: $('ev_form').serialize(true),
			    	onSuccess: function(transport){
			      		var response = transport.responseText || "no response text";
			      		//alert(response);
			      		var dati = response.split("|");
			      		if(dati[0] == "ko"){
							alert("Errore SQL. \nQuery: "+dati[1]+"\nErrore: "+dati[2]);
							return;
			      		}
			      		parent.win.close();
			      		link = "events.php?msg="+par;
			      		if(par != 1){
							link += "&second=1&offset=<?php print $offset ?>";
			      		}

						parent.document.location.href = link;
			      		//parent.win.close();
			    	},
			    	onFailure: function(){ alert("Si e' verificato un errore..."); }
			  });
}

var split_date = function(){
	date_time = $('sel3').value;
	date = date_time.substr(0, 10);
	time = date_time.substr(11, 5);
	$('sel3').value = date;
	$('time').value = time;
};
</script>
</head>
<body style="background-color: #FFFFFF">
    <p class="popup_header">Gestione eventi</p>
    <form action="dettaglio_evento.php?upd=1&offset=<?php print $offset ?>" id="ev_form" method="post">
    <div style="width: 550px; margin-top: 10px; margin-right: auto; margin-left: auto">
    <table style="width: 500px; margin-right: auto; margin-left: auto">
        <tr class="popup_row header_row">
            <td class="popup_title">Titolo</td>
            <td style="width: 350px">
                <input type="text" class="form_input" style="width: 350px" value="<?php if(isset($evs)) print utf8_decode($evs['abstract']) ?>" name="titolo" />
            </td>
        </tr>
        <tr class="popup_row">
            <td class="popup_title" style="width: 150px">Evento padre</td>
            <td style="width: 350px">
                <select class="form_input" style="width: 350px; background-color: white" class="form_input" name="evento_padre">
                	<option value="" selected="selected">Nessuno</option>
                <?php
				while($ev_p = $res_eventi_p->fetch_assoc()){
                ?>
                	<option <?php if($ev_p['id_evento'] == $evs['id_padre']) print("selected='selected'") ?> value="<?php print $ev_p['id_evento'] ?>"><?php print $ev_p['abstract'] ?></option>
                <?php } ?>
                </select>
            </td>
        </tr>
        <tr class="popup_row">
            <td class="popup_title" style="width: 150px">Classe</td>
            <td style="width: 350px">
                <select class="form_input" style="width: 350px; background-color: white" name="classe">
                	<option value="" selected="selected">Nessuna</option>
                <?php
				while($cls = $res_classi->fetch_assoc()){
                ?>
                	<option <?php if($cls['cls'] == $evs['classe']) print("selected='selected'") ?> value="<?php print $cls['cls'] ?>"><?php print $cls['cls'] ?></option>
                <?php } ?>
                </select>
            </td>
        </tr>
        <tr class="popup_row">
            <td class="popup_title" style="width: 150px">Data e ora evento</td>
            <td>
                <input class="form_input" type="text" name="data_evento" style="width: 70px" value="<?php print $my_date ?>" id="sel3" onchange="split_date()" readonly="readonly" />
                <script type="text/javascript">
	            Calendar.setup({
	                date		: new Date(2010, 01, 24, 12, 12, 12, 12),
					inputField	: "sel3",
					ifFormat	: "%d/%m/%Y %H:%M",
					showsTime	: true,
					firstDay	: 1,
					timeFormat	: "24"					
				});
	        	</script>
                <input class="form_input" type="text" name="ora_evento" id="time" style="width: 35px; margin-left: 10px" value="<?php print substr($my_ora, 0, 5) ?>" />
                <span style="margin-left: 20px; margin-right: 15px; color: #003366; font-weight: bold">Pubblico</span>
                <input type="checkbox" name="pub" <?php if($pubblico == 1) print "checked='true'" ?> />
                <span style="margin-left: 20px; margin-right: 10px; color: #003366; font-weight: bold">Modificabile</span>
                <input type="checkbox" name="upr" <?php if($modificabile == 1) print "checked='true'" ?> />
            </td>
        </tr>
        <tr class="popup_row">
            <td class="popup_title" style="width: 150px; vertical-align: top">Testo</td>
            <td style="width: 350px">
                <textarea style="width: 350px; height: 100px" name="testo" class="form_input"><?php if(isset($evs)) print utf8_decode($evs['testo']) ?></textarea>
            </td>
        </tr>
        <tr class="popup_row">
            <td colspan="2">
            	<input type="hidden" name="action" id="action" />
    			<input type="hidden" name="_i" id="_i" />
            </td>
        </tr>
        <tr class="popup_row">
            <td colspan="2" style="margin-right: 30px; text-align: right">
                <a href="#" onclick="go(<?php if(isset($_GET['id']) && $_GET['id'] != 0) print("3, ".$_REQUEST['id']); else print("1, 0"); ?>)" class="nav_link_first">Registra</a>|
                <?php if(isset($_GET['id']) && $_GET['id'] != 0){
                ?>
                <a href="#" onclick="go(2, <?php print $_REQUEST['id'] ?>)" class="nav_link">Cancella evento</a>|
                <?php
                }
                ?>
                <a href="#" onclick="parent.win.close()" class="nav_link_last">Chiudi</a>
            </td>
        </tr>
    </table>
    </div>
   </form>
</body>
</html>